package com.xmhu2009.applications.entity.enums;

import com.fasterxml.jackson.annotation.JsonValue;
import com.xmhu2009.common.mybatis.EnumCodeGetter;
import com.xmhu2009.common.mybatis.EnumDescriptionGetter;

/**
 * 可用枚举类;
 * 
 * @author Medeson.Zhang
 * @Date 2017年10月18日
 */
public enum YesOrNo implements EnumCodeGetter, EnumDescriptionGetter {
    YES("Y", "是"),
    NO("N", "否");

    private String code;

    private String description;

    private YesOrNo(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    @JsonValue
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static YesOrNo getEnumByCode(String code) {
        if (code.equals("Y"))
            return YES;
        else if (code.equals("N"))
            return NO;
        return null;
    }
}
